﻿using System;
using System.Numerics;

class Program
{
    static void Main()
    {
        string input = Console.ReadLine();
        string partialInput = string.Empty;
        string nineSystemNumber = "";

        for (int i = 0; i < input.Length; i++)
        {
            partialInput = partialInput + input[i];
            string currentDigit = ConvertStringToNumber(partialInput);
            if (currentDigit != "none")
            {
                nineSystemNumber = nineSystemNumber + currentDigit;
                partialInput = "";
            }
        }
        //Console.WriteLine(nineSystemNumber);
        BigInteger result = 0;

        for (int i = 0; i < nineSystemNumber.Length; i++)
        {
            BigInteger digit = BigInteger.Parse(nineSystemNumber[i].ToString());
            result = result + digit * PowerOfNine(nineSystemNumber.Length - i - 1);
        }
        Console.WriteLine(result);
    }

    static string ConvertStringToNumber(string digit)
    {
        string result = "none";
        switch (digit)
        {
            case "-!": 
                result = "0"; 
                break;
            case "**": 
                result = "1"; 
                break;
            case "!!!": 
                result = "2"; 
                break;
            case "&&": 
                result = "3"; 
                break;
            case "&-": 
                result = "4"; 
                break;
            case "!-": 
                result = "5"; 
                break;
            case "*!!!": 
                result = "6"; 
                break;
            case "&*!": 
                result = "7"; 
                break;
            case "!!**!-": 
                result = "8"; 
                break;
            default:
                break;
        }
        return result;
    }

    static BigInteger PowerOfNine(int power)
    {
        BigInteger result = 1;

        for (int i = 0; i < power; i++)
        {
            result = result * 9;
        }

        return result;
    }
}

